package lion.dev.image;

import java.util.ArrayList;
import java.util.List;

import lion.dev.image.format.FileFormatBMP;
import lion.dev.image.format.FileFormatCUR;
import lion.dev.image.format.FileFormatJPEG;
import lion.dev.image.format.FileFormatPCX;
import lion.dev.image.format.FileFormatPICT;
import lion.dev.image.format.FileFormatPNG;
import lion.dev.image.format.FileFormatPSD;
import lion.dev.image.format.FileFormatSER;
import lion.dev.image.format.FileFormatSunRaster;
import lion.dev.image.format.FileFormatTGA;
import lion.dev.image.format.FileFormatTIFF;

/**
 * @author lion
 * @date 2016年9月15日
 */
public class FileFormatWriterManager {

	public static List<FileFormatWriter> writers = new ArrayList<>();
	static {
		writers.add(new FileFormatJPEG());
		writers.add(new FileFormatBMP());
		writers.add(new FileFormatPNG());
		writers.add(new FileFormatTIFF());
		writers.add(new FileFormatCUR());
		writers.add(new FileFormatPCX());
		writers.add(new FileFormatPICT());
		writers.add(new FileFormatPSD());
		writers.add(new FileFormatSER());
		writers.add(new FileFormatTGA());
		writers.add(new FileFormatSunRaster());

	}

	public static FileFormatWriter getFormatWriter(String fileName) {

		for (FileFormatWriter writer : writers) {
			if (writer.canRead(fileName)) { return writer; }
		}
		return new FileFormatJPEG();
	}

}
